Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
Javascript: "Deprecated"

Screenshot of message

I am new in learning Javascript and as I was following the tutorial I found that console.log(name); got (name) struck through in such a way claiming it is "Deprecated".

If there is an explanation on what that means or what I should do to remove that strike, I would be really thankful.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Because you used var name = ..., TypeScript thinks you are referring to window.name, which TypeScript considers deprecated. You can fix this error by:

  1. Use a different variable identifier, like anotherName -

var anotherName = 'Bob'

console.log(anotherName)

  1. Move the code inside a function. -

(() => {
  var name = 'bob'

  console.log(name)
})()

about 4 years ago · Juan Pablo Isaza Relatório

0

I think this is due to the fact that a 'loose' variable in a browser, declared with var, outside of a function is just going to end up pointing to:

window.name 

And window.name has a special meaning, and is indeed deprecated.

It's a quirk of the language. If you didn't intend to create the variable in a global scope, you might be better off just declaring it in a function.

This will not have the same problem:

function main() {
   const name = 'Foo';
}
main();

Generally it's a good idea to avoid creating any global symbols unless you explicitly intend to.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda